package com.jkj.http.sys.service.impl;

import java.util.List;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import com.jkj.http.sys.dao.SysItemDetailDao;
import com.jkj.http.sys.entity.SysItemsDetail;
import com.jkj.http.sys.service.SysItemDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service
public class SysItemDetailServiceImp implements SysItemDetailService {
    @Autowired
    private SysItemDetailDao itemDetailDao;

    @Override
    public int getTotalCount(String itemId, String keyWord) {
        return itemDetailDao.getTotalCount(itemId, keyWord);
    }

    @Override
    public List<SysItemsDetail> getList( String itemId, String keyWord) {
        return itemDetailDao.getList( itemId, keyWord);
    }

    @Override
    public int insert(SysItemsDetail model) {
        model.setId(IdUtil.simpleUUID());
        model.setIsEnabled(model.getIsEnabled() == null ? "0" : "1");
        model.setIsDefault(model.getIsDefault() == null ? "0" : "1");
        model.setDeleteMark("0");
        model.setCreateTime(DateUtil.date());
        model.setModifyUser(model.getCreateUser());
        model.setModifyTime(model.getCreateTime());
        return itemDetailDao.insert(model);
    }

    @Override
    public int update(SysItemsDetail model) {
        model.setIsEnabled(model.getIsEnabled() == null ? "0" : "1");
        model.setIsDefault(model.getIsDefault() == null ? "0" : "1");
        model.setModifyTime(DateUtil.date());
        return itemDetailDao.update(model);
    }

    @Override
    public int delete(String primaryKey) {
        return itemDetailDao.delete(primaryKey);
    }

    @Override
    public SysItemsDetail get(String primaryKey) {
        return itemDetailDao.get(primaryKey);
    }

    @Override
    public List<SysItemsDetail> getItemDetailList(String strItemCode) {
        return itemDetailDao.getItemDetailList(strItemCode);
    }
}
